package com.scf.historyapproval.controller;

import com.scf.historyapproval.entity.History;
import com.scf.historyapproval.service.HistoryService;
import com.scf.uitl.ResponseResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-18-14:37
 */
@RestController
@RequestMapping("/history")
public class HistoryController {

    @Resource
    HistoryService historyService;

    @PutMapping("/insert")
    public boolean insert(@RequestBody History history){

        boolean add = historyService.add(history);
        return add;
    }

    @GetMapping("/select/{plid}")
    public ResponseResult select(@PathVariable("plid") int plid){
        List<History> history = historyService.get(plid);
        ResponseResult responseResult = new ResponseResult();
        responseResult.setCode(200);
        responseResult.setData(history);
        responseResult.setMessage("查询成功");
        return responseResult;
    }
}
